﻿/*======================================================================*\
|| #################################################################### ||
|| # manhtuantn Scroll Page Script                                    # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2010-2011 Ninja9x.Net. All Rights Reserved.      # ||
|| # Please do not remove this comment lines.                         # ||
|| # -------------------- LAST MODIFY INFOMATION -------------------- # ||
|| # Last Modify: 22-07-2011 03:00:00 PM by: Nguyen Manh Tuan         # ||
|| #################################################################### ||
\*======================================================================*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*\
|*-------Please specify source when using my code or a part of them-----*|
\*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

var manhtuantn_dy=100;
var manhtuantn_dtime=5;

function manhtuantn_gettop()
{
	try{
		if(window.pageYOffset!=undefined)
			return window.pageYOffset;
		return window.document.body.scrollTop;
	}catch(err)
	{
		try{
			return window.document.body.scrollTop;
		}catch(err2)
		{
			return 0;
		}
	}

}
function manhtuantn_croll_top()
{

	var manhtuantn_body_obj=window.document.body;
	var manhtuantn_cur_stop=manhtuantn_gettop();
	window.scrollBy (0,-manhtuantn_dy);
	var manhtuantn_new_stop=manhtuantn_gettop();
	if(manhtuantn_cur_stop>manhtuantn_new_stop)
		setTimeout("manhtuantn_croll_top()",manhtuantn_dtime);
	else
		document.getElementById("manhtuantn_scroll_down_img").style.display="block";
	return false;
}

function manhtuantn_croll_down()
{
	var manhtuantn_body_obj=window.document.body;
	var manhtuantn_cur_stop=manhtuantn_gettop();
	window.scrollBy (0,manhtuantn_dy);
	var manhtuantn_new_stop=manhtuantn_gettop();
	if(manhtuantn_cur_stop<manhtuantn_new_stop)
		setTimeout("manhtuantn_croll_down()",manhtuantn_dtime);
	else
		document.getElementById("manhtuantn_scroll_down_img").style.display="none";
	return false;
}

function manhtuantn_display_scroll_btn()
{
	var manhtuantn_body=window.document.body;
	var manhtuantn_height=manhtuantn_body.scrollHeight;
	var manhtuantn_top=manhtuantn_gettop();
	//document.getElementById("scroll").innerHTML=manhtuantn_top+"/"+manhtuantn_height;
	if(manhtuantn_top==0)
		document.getElementById("manhtuantn_scroll_up_img").style.display="none";
	else
		document.getElementById("manhtuantn_scroll_up_img").style.display="block";
	/*
	if(manhtuantn_top>=manhtuantn_height-manhtuantn_body.clientHeight)
		document.getElementById("manhtuantn_scroll_down_img").style.display="none";
	else
		document.getElementById("manhtuantn_scroll_down_img").style.display="block";
	*/
}
setInterval("manhtuantn_display_scroll_btn()",100);
document.write('<div style="position: fixed; width: 64px; right: -20px; bottom: 2px;">	<a href="#" onclick="return manhtuantn_croll_top()"><img border="0" id="manhtuantn_scroll_up_img" width="45px" src="images/icons/up.png"></a>	<a href="#" onclick="return manhtuantn_croll_down()"><img border="0" width="45px" id="manhtuantn_scroll_down_img" src="images/icons/down.png"></a></div></div>');